package com.chennan.workdir.invoiceapplication.api.rest.controller;

import com.chennan.common.domian.PageInfo;
import com.chennan.workdir.invoiceapplication.api.rest.controller.dto.InvoiceApplicationDTO;
import com.chennan.workdir.invoiceapplication.api.rest.controller.dto.InvoiceApplicationListConditionDTO;
import com.chennan.workdir.invoiceapplication.api.rest.controller.transform.FinanceInvoiceApplicationDTOModelConverter;
import com.chennan.workdir.invoiceapplication.domain.model.InvoiceApplicationListCondition;
import com.chennan.workdir.invoiceapplication.domain.service.InvoiceApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chennan
 * @createTime 2021年07月26日 17:10:00
 */
@Api("销项发票")
@RestController
@RequestMapping("invoice-application")
public class InvoiceApplicationController {

    @Autowired
    private InvoiceApplicationService invoiceApplicationService;

    @Autowired
    private FinanceInvoiceApplicationDTOModelConverter converter;

    @ApiOperation("查询销项票列表")
    @PostMapping("/list")
    public PageInfo<InvoiceApplicationDTO> listInvoiceApplications(@RequestBody InvoiceApplicationListConditionDTO condition){
        InvoiceApplicationListCondition invoiceApplicationListCondition = converter.toModel(condition);
        PageInfo<InvoiceApplicationDTO> invoiceApplications= invoiceApplicationService.listInvoiceApplications(invoiceApplicationListCondition);
        //        invoiceApplicationService
        return invoiceApplications;
    }

}
